package com.abc.invoke.server.service;

import com.abc.invoke.server.common.MergeInterfacesProxy;
import com.abc.invoke.services.interfaces.AccessControlInterface;
import com.google.common.collect.ImmutableClassToInstanceMap;

public class AccessControlManager {

	private final NexusWithSubNexuses nexusWithSubNexuses;
	private static volatile AccessControlManager instance=null;
	public AccessControlManager(Nexus nexus){
		nexusWithSubNexuses=new NexusWithSubNexuses(nexus);
		instance=this;
	}
	
	public static AccessControlManager getInstance(){
		return instance;
	}
	
	public AccessControlInterface getAci(){
		ImmutableClassToInstanceMap.Builder<Object> builder=ImmutableClassToInstanceMap.builder();
		builder.putAll(nexusWithSubNexuses.getSunNexuses());
		return MergeInterfacesProxy.newProxyInstance(builder.build(), AccessControlInterface.class);
	}
	
}
